import React from 'react';
import { Table, message } from 'antd';
import { connect } from 'react-redux';
import Api from 'Utils/api';
import CommonBg from 'Page/DispatchPage/Components/CommonBorder';


class ImportantSuperviseDetail extends React.PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      totalCount: 30,
      currentPage: 1,
      data: [],
      id: props.params.id
    };
  }
  componentDidMount() {
    this.initData();
  }
  initData() {
    const api = new Api({
      method: 'GET',
      path: `/warning/enterprise/result/${this.state.id}`,
      success: (res) => {
        this.setState({
          data: res
        });
      },
      error: (msg) => {
        message.error(msg);
      }
    });
    api.run();
  }
  generatorColumns() {
    return [
      {
        title: '序号',
        dataIndex: 'key',
        render: (text, record, index) => (
          <span>{index + 1}</span>
        )
      },
      {
        title: '项目',
        dataIndex: 'type',
        render: text => (
          <span >{text}</span >
        )
      },
      {
        title: '得分',
        dataIndex: 'score',
        render: text => (
          <span >{text}</span >
        )
      },
    ];
  }
  render() {
    const columns = this.generatorColumns();
    return (
      <CommonBg
        title="重点监管详情"
        content={
          <Table
            rowKey={record => record.type}
            columns={columns}
            bordered
            dataSource={this.state.data}
            pagination={false}
          />
        }
      />
    );
  }
}

function mapStateToProps(state) {
  return {
    ...state.routing,
    ...state.mapReducer
  };
}

export default connect(mapStateToProps)(ImportantSuperviseDetail);
